package com.hdstcloud.device.service.bo;

import com.frame.base.comm.persistence.BoBaseData;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import com.frame.base.comm.persistence.annotaion.BoConstraint;

import com.frame.base.comm.persistence.annotaion.PersisCondition;
import com.frame.base.comm.persistence.annotaion.PersisMethod;
import com.frame.base.comm.persistence.annotaion.SoleHolder;
import com.frame.base.comm.persistence.ConditionMatchMode;

import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import java.util.List;

@PersisMethod(name = "getByDevId", condtions = {
        @PersisCondition(obj = "infoList", name = "id", valType = String.class, mode = ConditionMatchMode.EQUALS)})


@PersisMethod(name = "getModelByDevIds", condtions = {
        @PersisCondition(obj = "infoList", name = "id", valType = String.class, mode = ConditionMatchMode.IN)})


@Data
@NoArgsConstructor
@AllArgsConstructor
public class BoModel extends BoBaseData {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY, generator = "JDBC")
    private Integer id;//设备型号ID
    private String name;//型号名称
    private String manufacture;//厂商

    private String remark;//备注

    private Integer thresholdValue;//时间阈值（单位秒 ）
    private String searchName;//检索名称

    //约束BoModelItem的type必须符合这个条件
    @BoConstraint(dbColumn = "type", value = "1")
    private List<BoModelItem> attr;//comm属性项
    @BoConstraint(dbColumn = "type", value = "2")
    private List<BoModelItem> data;//数据项//数据库设计思维
    @BoConstraint(dbColumn = "type", value = "3")
    private List<BoModelItem> config;//配置项，带默认值

    @SoleHolder
    private List<BoInfo> infoList;//设备信息列表

    public BoModel(Integer id) {
        this.id = id;
    }

    public BoModel(Integer id, String name) {
        this.id = id;
        this.name = name;
    }
}
